package main

import (
	"fmt"
	"gitee.com/masaichi/mastool/pipe"
)

func main() {
	data := []int{1, 2, 3, 4, 5, 6, 8, 9, 9, 0}
	//单项处理，如果需要汇总，要自己在外层进行
	resCh := pipe.PipeLineDo(func(ch pipe.PipeLineCommonChan) {
		for _, v := range data {
			//将数据项塞入管道
			ch <- v
		}
	}, func(chanItem interface{}) interface{} {
		//进行倍数处理，处理需要断言
		return chanItem.(int) * chanItem.(int)
	}, func(chanItem interface{}) interface{} {
		if chanItem.(int)%2 != 0 {
			return chanItem
		}
		return nil
	})
	var sum int
	for v := range resCh {
		sum += v.(int)
		fmt.Println("result: ", sum)
	}
}
